package com.xyz.study.design_mode.q_observer;

import com.xyz.study.design_mode.q_observer.mode.UserChangeCreateTokenListener;
import com.xyz.study.design_mode.q_observer.mode.UserChangeEvent;
import com.xyz.study.design_mode.q_observer.mode.UserChangeInvalidTokenListener;

/**
 * 管理状态：其一 ---- 观察者模式
 * 角色：Client
 * 当观察对象的状态发生变化时通知观察者
 * @author XYZ
 * @version 1.0.0
 * @since 2020/6/22
 */
public class ObserverMain {

    public static void main(String[] args) {
        UserChangeEvent userChangeEvent = new UserChangeEvent("XiaoMing");
        userChangeEvent.addListener(new UserChangeInvalidTokenListener());
        userChangeEvent.addListener(new UserChangeCreateTokenListener());
        userChangeEvent.eventChanged("DaHong");
    }
}
